package com.example.demo.service.impl;

import com.example.demo.mappers.UserMapper;
import com.example.demo.pojo.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Service
public class UserServiceImpl implements UserService{
    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public int register(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public int personalManage(User user) {
        return userMapper.updateUserById(user);
    }

    @Override
    public int delete(User user) {
        return userMapper.deleteUserById(user);
    }


//    @Autowired(required = false)
//    private UserService userService;
//    @Autowired(required = false)
//    private UserMapper userMapper;
//
//    //注册
//    @RequestMapping("/getUsers")
//    @ResponseBody
//    public int register(User user) {
//        return userMapper.addUser(user);
//    }
//
//    @RequestMapping("/add")
//    @ResponseBody
//    public String addUser() {
//        User user = new User();
//        user.setSno("23434");
//        user.setCno("23");
//        user.setGrade(99);
//        int reuslt = userService.register(user);
//        if (reuslt == 1) {
//            return "添加成功";
//        } else {
//            return "添加失败";
//        }
//    }
}
